<%@ taglib prefix="s" uri="/struts-tags"%> 
  
<script type="text/javascript"> 
	//URL to call ajax
	var AUDIT_LIST = "<s:url value='/auditlog/auditlogAjax_SearchAuditLog'/>";

	function onLoadSuccess(data) {
		if (data.total == 0) {
			$("#message_div").html("");
		} else {
			$("#message_div").html("");
		}
	}
	
	function doSearchAuditlog() { 
	    $('#dgg').datagrid('load',{
	    	'searchuid': $('#searchuid').val(),
	    	'activityType': $('#activityType').val(),
	    	'startDate': $('#startDate').val(),
	    	'endDate': $('#endDate').val()
	    });
	}

	$(document).ready(function() {
		
		$(".datetimepicker").datepicker({
			dateFormat: 'dd/mm/yy'
		});

		$('#search_button').click(function(){
			doSearchAuditlog();
		});

	});

</script>

<center>
	<h2>Admin Module Audit Logs</h2>
</center>
<center>
	<h1>Select User / Account</h1>
</center>

<div></div>

	<form id="searchAuditlogForm" method="post">
		<table width="70%">
			<tr>
				<td><label>Select Activity Date:</label></td>
				<td>
					<input type="text" name="startDate" id="startDate" class="datetimepicker" placeholder="Start Date"/>
					<label> To : </label>
					<input type="text" name="endDate" id="endDate" class="datetimepicker" placeholder="End Date"/>
				</td>
				<td>&nbsp;</td>
			</tr>
			<tr>
				<td><label>Log Action: </label></td> 
				<td>
					<select name="activityType" id="activityType">
						<option value="">--Log Type--</option>
						<option value="ACCESS">Access</option>
						<option value="ACTIVITY">Activity</option>
					</select> 
				</td>
				<td>
				</td>
			</tr>
			<tr>
				<td><label>Enter User ID: </label></td> 
				<td>
					<input type="text" style="width:143px" name="searchuid" id="searchuid" value=""/> 
				</td>
				<td>
					<a href="#" class="easyui-linkbutton" id="search_button">Search</a>
				</td>
			</tr>
		</table>
	</form>
<br />
	<div id="message_div"></div>
	<table id="dgg" class="easyui-datagrid" style="width:930px;height:auto" 
			data-options=" 
				scrollbarSize:0,
				rownumbers:true,  
                singleSelect:true,  
                autoRowHeight:false,  
                pagination:true, 
                singleSelect: true,
                checkOnSelect: false,
                selectOnCheck: false,  
                pageSize:50,
				url: AUDIT_LIST,
				loadFilter: function(data) {
					if (data.csrLogInfoList !== null && data.csrLogInfoList !== undefined) {
						return {rows: data.csrLogInfoList, total: data.pagingInfo.total}
					} else {
						return {rows: [], total: 0}
					}					
				},
				onLoadSuccess: onLoadSuccess ">
				
		<thead> 
			<tr> 
				<th data-options="field:'activityDate',width:150,align:'center'">Action Date</th>
				<th data-options="field:'activityname',width:150,align:'center'">Action Name</th>
				<th data-options="field:'userid',width:100,align:'center'">User ID</th>
				<th data-options="field:'ipaddr',width:100,align:'center'">IP Address</th>
				<th data-options="field:'userfield1',width:420,align:'center'">Remarks</th>
			</tr>
		</thead>
	</table>
